﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace XBoshiGFS.forms
{
    public partial class ProcessBarForm : Form
    {
        public ProcessBarForm()
        {
            InitializeComponent();
        }


        public void StartTimer(int seconds) {
            this.progressBar1.Maximum = seconds * 2;
            this.progressBar1.Minimum  = 0; 
            timer1.Interval = 500;
            timer1.Tick += new EventHandler(timer1_Tick);
            timer1.Start();

        }

        void timer1_Tick(object sender, EventArgs e)
        {

            var value = this.progressBar1.Value+1;
            if (value > this.progressBar1.Maximum) {
                value = (int)(this.progressBar1.Maximum * 0.83);
            
            }
                

            System.Windows.Forms.MethodInvoker invoker = () => this.progressBar1.Value = value;

            if (this.progressBar1.InvokeRequired)
            {
                this.progressBar1.Invoke(invoker);
            }
            else
            {
                invoker();
            }

           ;              
   
        }
        
    }
}
